package com.example.contentproviderdemotest;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ContentResolver;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.google.android.material.bottomappbar.BottomAppBar;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button selectButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        selectButton = findViewById(R.id.query);
        selectButton.setOnClickListener(this);


//        ContentValues values = new ContentValues();
//        values.put("title", "testcase1 ");
//        values.put("content", "ContentProvider-put");
//        resolver.insert(uri, values);
    }

    @Override
    public void onClick(View v) {
        Uri uri = Uri.parse("content://com.test.provider.MyContentProvider/user");
        ContentResolver resolver = getContentResolver();
        Cursor query = resolver.query(uri, null, null, null, null);
        while (query.moveToNext()){
            Log.e("maintest", "onCreate: id :" + query.getString(0) + "name: " + query.getString(1) );
        }
    }
}